/**
 * Copyright 2009-2011 xiaonei.com All right reserved.
 * This software is the confidential and proprietary information of Xiaonei.com ("Confidential Information"). 
 * You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement you entered into with Xiaonei.com.
 * Create by XiaoNeiAntiSpamTeam
 *
 */

package com.xiaonei.storm.adapter.example;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.xiaonei.storm.adapter.IceStormAdapter;
import com.xiaonei.storm.adapter.IceStormListener;

/**
 * @ClassName: IceStormListenerExample
 * @Description: TODO
 * @author shaohui.liu shaohui.liu@opi-corp.com
 * @date Apr 23, 2010 12:21:04 PM
 * 
 */
public class IceStormListenerExample extends IceStormListener {

    private Log logger = LogFactory.getLog(IceStormListenerExample.class);

    /* (非 Javadoc)
     * <p>Title: handle</p>
     * <p>Description: </p>
     * @param message
     * @see com.xiaonei.storm.adapter.IceStormListener#handle(java.lang.String)
    */
    @Override
    public void handle(String message) {
        logger.info(message);
    }

    public static void main(String[] args) {
        String topic = "topic";
        String message = "hello world!";
        IceStormListenerExample iceStormListenerExample1 = new IceStormListenerExample();
        IceStormListenerExample iceStormListenerExample2 = new IceStormListenerExample();

        IceStormAdapter.getInstance().subscribe(topic, iceStormListenerExample1);
        IceStormAdapter.getInstance().subscribe(topic, iceStormListenerExample2);

        IceStormAdapter.getInstance().notify(topic, message);

        while (true) {
            try {
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
